package com.gs.gaosheng.controller;

import com.gs.common.annotation.Log;
import com.gs.common.core.controller.BaseController;
import com.gs.common.core.domain.AjaxResult;
import com.gs.common.core.page.TableDataInfo;
import com.gs.common.enums.BusinessType;
import com.gs.common.utils.poi.ExcelUtil;
import com.gs.gaosheng.domain.GsGoodsStatus;
import com.gs.gaosheng.service.GsGoodsStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品和商品活动关联表Controller
 *
 * @author yy
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/gaosheng/goodsstatus")
public class GsGoodsStatusController extends BaseController
{
    @Autowired
    private GsGoodsStatusService gsGoodsStatusService;

    /**
     * 查询商品和商品活动关联表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GsGoodsStatus gsGoodsStatus)
    {
        startPage();
        List<GsGoodsStatus> list = gsGoodsStatusService.selectGsGoodsStatusList(gsGoodsStatus);
        return getDataTable(list);
    }

    /**
     * 导出商品和商品活动关联表列表
     */
    @Log(title = "商品和商品活动关联表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GsGoodsStatus gsGoodsStatus)
    {
        List<GsGoodsStatus> list = gsGoodsStatusService.selectGsGoodsStatusList(gsGoodsStatus);
        ExcelUtil<GsGoodsStatus> util = new ExcelUtil<GsGoodsStatus>(GsGoodsStatus.class);
        return util.exportExcel(list, "goodsstatus");
    }

    /**
     * 获取商品和商品活动关联表详细信息
     */
    @GetMapping(value = "/{goodsStatusId}")
    public AjaxResult getInfo(@PathVariable("goodsStatusId") Long goodsStatusId)
    {
        return AjaxResult.success(gsGoodsStatusService.selectGsGoodsStatusById(goodsStatusId));
    }

    /**
     * 新增商品和商品活动关联表
     */
    @Log(title = "商品和商品活动关联表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GsGoodsStatus gsGoodsStatus)
    {
        return toAjax(gsGoodsStatusService.insertGsGoodsStatus(gsGoodsStatus));
    }

    /**
     * 修改商品和商品活动关联表
     */
    @Log(title = "商品和商品活动关联表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GsGoodsStatus gsGoodsStatus)
    {
        return toAjax(gsGoodsStatusService.updateGsGoodsStatus(gsGoodsStatus));
    }

    /**
     * 删除商品和商品活动关联表
     */
    @Log(title = "商品和商品活动关联表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsStatusIds}")
    public AjaxResult remove(@PathVariable Long[] goodsStatusIds)
    {
        return toAjax(gsGoodsStatusService.deleteGsGoodsStatusByIds(goodsStatusIds));
    }
}
